﻿<UserControl x:Class="MissedMemo.MeatAndCheeseDisc.OrderEntry.viewOrderEditPanel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderEntry"
    Height="540" Width="400">

    <UserControl.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="resOrderListItemStyles.xaml" />
                <ResourceDictionary Source="resTabControlTemplate.xaml" />
            </ResourceDictionary.MergedDictionaries>
            
            
            <Style x:Key="OKCancelButtonPanelStyle" TargetType="DockPanel" >
                <Style.Resources>
                    <Style TargetType="Button">
                        <Setter Property="DockPanel.Dock" Value="Right" />
                        <Setter Property="Width" Value="90" />
                        <Setter Property="Height" Value="23" />
                    </Style>
                </Style.Resources>
                <Setter Property="LastChildFill" Value="false" />
            </Style>
            
            <local:OrderStateToViewEnabledConverter x:Key="OrderStateToViewEnabledConverter" />

        </ResourceDictionary>
    </UserControl.Resources>

    
    <Border Background="{StaticResource brushEditPanel}" BorderBrush="{StaticResource brushEditPanelBorder}"
            BorderThickness="2" Margin="5,5,6,8" CornerRadius="4" >

        <Grid Margin="12" >

            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            
            <TabControl Name="tabControl" Grid.Row="0" Grid.RowSpan="2" >
                <TabItem Header="{Binding NowServingNumber, Converter={StaticResource FormattedTextConverter}, ConverterParameter='Order# {0}'}"
                         IsSelected="True" MinHeight="24" MinWidth="60" >
                    <local:viewOrderDetails x:Name="orderDetails" Width="auto" Height="auto" FontWeight="Normal"
                           IsEnabled="{Binding ProcessingState, Converter={StaticResource OrderStateToViewEnabledConverter}}" />
                </TabItem>
                <TabItem Header="{Binding Customer.Name}"  MinHeight="24" MinWidth="60" >
                    <local:viewCustomerDetails x:Name="customerDetails" Width="auto" Height="auto" FontWeight="Normal"
                           IsEnabled="{Binding ProcessingState, Converter={StaticResource OrderStateToViewEnabledConverter}}" />
                </TabItem>
            </TabControl>
            
            <local:DeliveryOptionsSelector Grid.Row="0" HorizontalAlignment="Right" Margin="14,-2"
                   IsEnabled="{Binding ProcessingState, Converter={StaticResource OrderStateToViewEnabledConverter}}" />
            
            <DockPanel Grid.Row="2" Margin="0,10,0,0" Style="{StaticResource OKCancelButtonPanelStyle}" >
                <Button Content="Cancel" Click="OnDone" Margin="3,0,0,0" />
                <Button Content="Save Changes" Click="OnDone" Command="ApplicationCommands.Save" IsEnabled="{Binding UnsavedChanges}"/>
            </DockPanel>

        </Grid>
        
    </Border>


</UserControl>
